package com.example.boot.controller;

import com.example.boot.service.UserService;
import com.example.boot.pojo.Users;
import com.example.boot.service.ifelse.EatLunch;
import com.example.boot.service.ifelse.factory.StrategyFactoryAware;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
public class UserController {

    @Autowired
    private UserService userService;

    @RequestMapping("/adduser")
    public void addUser(@RequestBody Users users) {
        userService.addUsers(users);
    }

    @RequestMapping("/all")
    public List<Users> getUserAll() {
        return userService.getAll();
    }

    @RequestMapping("/aware/{week}")
    public String findFood(@PathVariable String week) {
        EatLunch lunch = StrategyFactoryAware.getLunch(week);
        return lunch.ChoosingFood();
    }

}
